package command.respondente;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import model.Respondente;

import command.ICommand;
import dao.RespondenteDAO;

public class EditarRespondenteViewCommand implements ICommand{

	public String execute(HttpServletRequest request) throws ServletException,IOException {

		String cod = request.getParameter("codigo");
		int codigo = Integer.parseInt(cod);
		
		RespondenteDAO dao = new RespondenteDAO();
		try {
			Respondente respondente = dao.getRespondentePeloCodigo(codigo);
			request.setAttribute("respondente", respondente);
			return "/paginas/respondente/editar_respondente.jsp";
		} catch (SQLException e) {
			e.printStackTrace();
			return "/paginas/respondente/editar_respondente.jsp?erro=1";
		}
		
	}

}
